package com.csr.csrcheck.controller;

import com.csr.csrcheck.pojo.Abnormal_products;
import com.csr.csrcheck.pojo.Product;
import com.csr.csrcheck.service.MilitaryService;
import com.csr.csrcheck.service.ex.ClinicException;
import com.csr.csrcheck.util.JsonResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@RequestMapping({"military"})
@RestController
public class MilitaryController extends BaseController {
    private static final Logger log = LoggerFactory.getLogger(com.csr.csrcheck.controller.MilitaryController.class);

    @Resource
    private MilitaryService militaryService;

    @GetMapping({"militarylist"})
    public JsonResult<List<Product>> Militarylist(HttpServletResponse response) throws IOException, ServletException {
        List<Product> list = this.militaryService.getMilitarylist();
        if (list == null)
            throw new ClinicException("");
        return new JsonResult(Integer.valueOf(0), "json", list);
    }

    @GetMapping({"militarylist2"})
    public JsonResult<List<Product>> Militarylist2(HttpServletResponse response) throws IOException, ServletException {
        List<Product> list = this.militaryService.getMilitarylist2();
        if (list == null)
            throw new ClinicException("");
        return new JsonResult(Integer.valueOf(0), "json", list);
    }

    @GetMapping({"legitimate"})
    public JsonResult<List<Product>> getAllLegitimate_producers(HttpServletResponse response) throws IOException, ServletException {
        List<Product> list = this.militaryService.getAllLegitimate_producers(3);
        if (list == null)
            throw new ClinicException("");
        return new JsonResult(Integer.valueOf(0), "json", list);
    }

    @GetMapping({"medical"})
    public JsonResult<List<Abnormal_products>> getAllabnormal_products(HttpServletResponse response) throws IOException, ServletException {
        List<Abnormal_products> list = this.militaryService.getAllabnormal_products(3);
        if (list == null)
            throw new ClinicException("");
        return new JsonResult(Integer.valueOf(0), "json", list);
    }
}
